// MovPlayCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "configgui.h"
#include "MovPlayCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

BOOL CMovPlayCtrl::m_bRegistered = Register();

BOOL CMovPlayCtrl::Register()
{
    // Register the window class of the control
    WNDCLASS wc;
    wc.style = CS_GLOBALCLASS
             | CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = MovPlayCtrlWndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = NULL;
    wc.hIcon = NULL;
    wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "MovPlayCtrl";

    if (!::RegisterClass(&wc)) {
        ASSERT(0);
        return FALSE;
    } 
    return TRUE;
}

LRESULT CALLBACK MovPlayCtrlWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uiMsg) {
    case WM_NCCREATE: {
        // Create a C++ object to handle the messages
        CMovPlayCtrl* pCtrl = new CMovPlayCtrl;
        ASSERT(pCtrl);
        // Attach the window handle to the new object
        BOOL b = pCtrl->SubclassWindow(hWnd);
        ASSERT(b);
        return b;
        } break;

    default:
        return ::DefWindowProc(hWnd, uiMsg, wParam, lParam);
    }
}

/////////////////////////////////////////////////////////////////////////////
// CMovPlayCtrl

IMPLEMENT_DYNCREATE(CMovPlayCtrl, CWnd)

CMovPlayCtrl::CMovPlayCtrl()
{
}

CMovPlayCtrl::~CMovPlayCtrl()
{
}

WNDPROC* CMovPlayCtrl::GetSuperWndProcAddr()
{
    // Provide a place for MFC's subclassing
    // mechanism to store the super-class pointer
    static WNDPROC pfnSuper = NULL;
    return &pfnSuper;
}

BEGIN_MESSAGE_MAP(CMovPlayCtrl, CWnd)
	//{{AFX_MSG_MAP(CMovPlayCtrl)
	ON_WM_NCDESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CMovPlayCtrl message handlers

void CMovPlayCtrl::OnNcDestroy() 
{
	CWnd::OnNcDestroy();
	
	// TODO: Add your message handler code here
	ASSERT(m_hWnd == NULL);
    // Destroy this object since it won't be destroyed otherwise
    delete this;
}
